package net.dgg.liuyinglong.plugin;

import java.io.*;

/**
 * 文件操作
 */
public class AppendFile {
    public static final String huanHang = "\r\n";

    /**
     * 追加文字内容
     *
     * @param pathname
     * @param txt
     */
    public static void txt(String pathname, String txt) {
        FileWriter fw = null;
        try {
            //如果文件存在，则追加内容；如果文件不存在，则创建文件
            File f = new File(pathname);
            fw = new FileWriter(f, true);
        } catch (IOException e) {
            e.printStackTrace();
        }
        PrintWriter pw = new PrintWriter(fw);
        pw.println(txt);
        pw.flush();
        try {
            fw.flush();
            pw.close();
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
